using UnityEngine;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System;
using System.Collections.Generic;

public class SceneManagement{
	
	//Transform trans;
	
	private static SceneManagement instance;
	
	public static SceneManagement GetInstance(){
		if(instance == null)
			instance = new SceneManagement();
		
		return instance;
	}
	
	SceneManagement()
	{
		
	}
	
	public string nextScene = "";
	public string preScene = "";
	public bool needBar = false;
	
	public void SwitchScene(int sceneIndex){
		Application.LoadLevel(sceneIndex);
	}
	
	public void SwitchScene(string SceneName , bool needProcessBar){
		nextScene = SceneName;
		
		preScene = Application.loadedLevelName;
		
		needBar = needProcessBar;
        //Application.LoadLevelAsync(nextScene);
        Application.LoadLevel("TempScene");
	}
	
	public void ReturnPreviousScene(){
		SwitchScene(preScene,true);
	}
	
	/*
	public void SceneXmlLoader(string path,List<Transform> transformList){
		if(File.Exists(path)) {
			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.Load(path);
			XmlNodeList nodeList = xmlDoc.SelectNodes("SceneRoot/Transform");
			foreach(XmlNode node in nodeList){
				XmlElement element = (XmlElement)node;
				trans.name = element.GetAttribute("name");
				trans.tag = element.GetAttribute("tag");
				
				Vector3 transformPosAndRotation;
				XmlElement childElement = (XmlElement)element.FirstChild;
				transformPosAndRotation.x = float.Parse(childElement.GetAttribute("x"));
				transformPosAndRotation.y = float.Parse(childElement.GetAttribute("y"));
				transformPosAndRotation.z = float.Parse(childElement.GetAttribute("z"));
				trans.position = transformPosAndRotation;
				
				childElement = (XmlElement)element.LastChild;
				transformPosAndRotation.x = float.Parse(childElement.GetAttribute("x"));
				transformPosAndRotation.y = float.Parse(childElement.GetAttribute("y"));
				transformPosAndRotation.z = float.Parse(childElement.GetAttribute("z"));
				trans.eulerAngles = transformPosAndRotation;
				
				trans.localScale = ScaleRate() * Vector3.one;
				
				transformList.Add(trans);
			}
		} else {
			Debug.Log("File does not exist!");
		}
	}
	*/
	
	float ScaleRate(){
		return 1;
	}
}
